<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>

<body>
    <table>
        <%
            String options = request.getParameter("selection");
            session.setAttribute("selecthead",options);
            String groups="group";
            
        Connection db_conn = null;
        Statement statement = null;
        PreparedStatement pstmt;
        ResultSet rs;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            String url= "jdbc:mysql://localhost:3306/db";
            db_conn = DriverManager.getConnection( url,"root", "root" );
            statement = db_conn.createStatement();
            //rs=statement.executeUpdate(query);
           
            String query="select * from "+options+"";
            rs=statement.executeQuery(query);
                %>
                <table>
    <form action="delete.jsp" method="post">
            <select name="specificselection">
             
            
 
                <%
                     if(options.equals(groups))
                        {
                    while (rs.next()) { // parse the results
                    
                       String passwd=rs.getString("group_name"); 
                            out.println("<option value="+passwd+">"+passwd+"</option>");
                out.println(passwd);
                        }
                            }
                            else
                            {
                               while (rs.next()) { // parse the results
                            String passwd=rs.getString("name");
                            out.println("<option value="+passwd+">"+passwd+"</option>");
                out.println(passwd);
                        }
                    
                }%>
                </select>
            
            <input type="submit" value="delete">
        </form>
    </table><%
                db_conn.close();
        } catch(SQLException e){
            e.printStackTrace();
            out.println("sql not found");
            out.println(e);
        } catch(ClassNotFoundException e){
            e.printStackTrace();
            out.println(e);
        }
            %>
        </table>
</body>
